Repository navigation
Feeding MP3 audio to the MP4 muxer only while something reads MP4 - #100
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoStop buffering MP3 audio when no MP4 consumer is active
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
With MP3 audio on and nobody reading
/video.mp4or recording, Divinus slowly uses up the memory of the camera. Seen on a Ruision F8 board (FH8856V200): +312 kB in 90 s at 32 kbit/s; a second board, left running for 30 hours, had its streamer at 22.8 MB (normally 3.4 MB) with 7.3 MB of memory left.Why
aenc_thread()(src/media.c) passes every MP3 frame tomp4_ingest_audio(), which appends it to the muxer's audio bufferbuf_aud. Onlymp4_set_slice()empties that buffer, and it is called only fromsend_mp4_to_client()while an MP4 client is connected and from the recorder while it records. The MP3 encoder also runs for RTSP, RTMP and/audio.mp3, so with RTSP on (the default) and no MP4 reader,buf_audgrows for as long as the program runs.What this changes
any_http_mp4()insrc/server.c(declared inserver.h), the MP4-only twin ofany_http_audio().aenc_thread()callsmp4_ingest_audio()only whenrecord_active()orany_http_mp4()says that someone will empty the buffer.How it was checked
./build.sh fhan-v2, no new warnings;./test.sh -apasses.Effect on other platforms
Shared code, every target with audio. Users who read
/video.mp4or record: unchanged while they are there (audio is fed as before). The first fragment after an MP4 client connects carries only the audio from that moment on, instead of whatever had piled up before.🤖 Generated with Claude Code